﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tamir.SharpSsh;
using System.Threading;
using Model;
using SSHTool.RRU_QUERY;
using System.Diagnostics;

namespace SSHTool
{
    public partial class MainWindowShow : Form
    {
        private bool IsCanQueryFSIH = false;

        TabPage tp_FSMF = new TabPage();
        TabPage tp_FSIH = new TabPage();
        TabPage tp_TPT = new TabPage();
        TabPage tp_Telnet = new TabPage();

        private string Ip = string.Empty;
        private string User = string.Empty;
        private string PWD = string.Empty;
        private int DK = 0;

        /*连接超时5分钟*/
        private int CommandTimeoutSeconds = 300;

        public static SshExec exec = null;
        public static SshShell execShell = null;

        Renci.SshNet.SshClient ssh_Client = null;

        ZeeiCommon.Telnet.TelnetBSC telnetRRU = null;
        ZeeiCommon.Telnet.ScriptingTelnet telnet = null;
        Tamir.SharpSsh.ShellHelp shell = null;

        public bool IsConnected = false;

        /*修改 此值为变量*/
        private int TX_High_Alarm = 0;
        private int TX_Low_Alarm = 0;
        private int TX_High_Warning = 0;
        private int TX_Low_Warning = 0;

        private int RX_High_Alarm = 0;
        private int RX_Low_Alarm = 0;
        private int RX_High_Warning = 0;
        private int RX_Low_Warning = 0;


        //private int RXMin = 363;
        //private int RXMax = 11220;
        //private int TXMin = 3020;
        //private int TXMax = 11220;



        private string[] SFPSpec;
        private int[] SFPSpecLength;

        public MainWindowShow()
        {
            InitializeComponent();
            InitControl();
        }
        public void InitControl()
        {
            ConnectionType.Items.Add("FSMF");
            ConnectionType.Items.Add("FSIH");

            ConnectionType_RRU.Items.Add("TELNET");
            ConnectionType_RRU.Items.Add("SSH");
        }



        private void 手动命令模式ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HandHandleMode x = new HandHandleMode();
            x.Ip = txt_IP.Text.Trim();
            x.User = txt_user.Text.Trim();
            x.PWD = txt_pwd.Text.Trim();
            x.ShowDialog();

        }



        private void button1_Click(object sender, EventArgs e)
        {
            if (ConnectionType.Text == "")
            {
                MessageBox.Show("请选择BBU类型!");
            }
            else
            {

            }
        }



        private void txt_IP_KeyPress(object sender, KeyPressEventArgs e)
        {
            TextBox textbox = (TextBox)sender;
            e.Handled = true;
            if ((e.KeyChar >= 47 && e.KeyChar <= 58) || e.KeyChar == 8)
            {
                e.Handled = false;
            }
            if (e.KeyChar == 46)                       //小数点        
            {
                if (textbox.Text.Length <= 0)
                {
                    e.Handled = true;           //小数点不能在第一位   
                }
                else
                {
                    e.Handled = false;
                }
            }
        }


        private void btn_Connect_Click(object sender, EventArgs e)
        {

            Ip = txt_IP.Text.Trim();
            User = txt_user.Text.Trim();
            DK = CommonClass.StringHander.Common.GetInt(txt_pwd.Text.Trim()); // CommonClass.StringHander.Common.GetInt 这个是 string 转int用吧  不成功 好像 返回0de  
            PWD = txt_pwd.Text.Trim();

            if (txt_IP.Text.Trim() == string.Empty)
            {
                MessageBox.Show("IP必须填写！");
                return;
            }
            if (txt_user.Text.Trim() == string.Empty)
            {
                MessageBox.Show("用户名必须填写！");
                return;
            }
            if (txt_pwd.Text.Trim() == string.Empty)
            {
                MessageBox.Show("密码必须填写！");
                return;
            }
            if (ConnectionType.Text == "")
            {
                MessageBox.Show("请选择BBU类型!");
                return;
            }

            try
            {
                ssh_Client = new Renci.SshNet.SshClient(Ip, User, PWD);
                ssh_Client.Connect();

                if (ssh_Client.IsConnected)
                {
                    lab_BBU_Connect_Info.Text = string.Format("已连接", Ip, ConnectionType.Text);
                    lab_ConnectINfo_hide.Text = ConnectionType.Text.ToString();/*lab_ConnectINfo_hide 隐藏的属性 绑定当前的 BBU类型*/
                    lab_BBU_Connect_Info.BackColor = System.Drawing.Color.Green;
                }
                else
                {
                    lab_BBU_Connect_Info.Text = "连接失败";
                    lab_BBU_Connect_Info.BackColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception ex)
            {
                lab_BBU_Connect_Info.Text = "连接失败";
                lab_BBU_Connect_Info.BackColor = System.Drawing.Color.Red;

                MessageBox.Show(ex.ToString());//最好做日志记录 log
            }



            Ip = txt_ip_rru.Text.Trim();
            User = txt_user_rru.Text.Trim();
            DK = CommonClass.StringHander.Common.GetInt(txt_pwd.Text.Trim());
            PWD = txt_pwd_rru.Text.Trim();
            string ConnectionType_RRU_V = ConnectionType_RRU.Text.Trim();

            if (Ip.Trim() == string.Empty)
            {
                MessageBox.Show("RRU_IP必须填写！");
                return;
            }
            if (User.Trim() == string.Empty)
            {
                MessageBox.Show("RRU_用户名必须填写！");
                return;
            }
            if (PWD.Trim() == string.Empty)
            {
                MessageBox.Show("RRU_密码必须填写！");
                return;
            }
            if (ConnectionType_RRU.Text == "")
            {
                MessageBox.Show("请选择RRU类型!");
                return;
            }

            try
            {


                if (ConnectionType_RRU_V == "TELNET")
                {
                    ZeeiCommon.Telnet.TelnetBSC telnetRRU = new ZeeiCommon.Telnet.TelnetBSC();
                    telnetRRU.Address = "192.168.253.206";
                    telnetRRU.Port = 2323;

                    telnet = new ZeeiCommon.Telnet.ScriptingTelnet(telnetRRU.Address, telnetRRU.Port, 30);
                    {
                        telnet.Connect();
                    }
                    if (telnet.IsConnected())
                    {
                        lab_RRU_Connect_Info.Text = string.Format("已连接", Ip, ConnectionType_RRU.Text);
                        lab_RRU_Connect_Info.BackColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        lab_RRU_Connect_Info.Text = "连接失败";
                        lab_RRU_Connect_Info.BackColor = System.Drawing.Color.Red;
                    }
                }



                if (ConnectionType_RRU_V == "SSH")
                {
                    shell = new Tamir.SharpSsh.ShellHelp();
                    try
                    {
                        if (shell.OpenShell(txt_ip_rru.Text.Trim(), txt_user_rru.Text.Trim(), txt_pwd_rru.Text.Trim(), 22))
                        {
                            lab_RRU_Connect_Info.Text = string.Format("已连接", Ip, ConnectionType_RRU.Text);
                            lab_RRU_Connect_Info.BackColor = System.Drawing.Color.Green;
                        }
                        else
                        {
                            lab_RRU_Connect_Info.Text = "连接失败";
                            lab_RRU_Connect_Info.BackColor = System.Drawing.Color.Red;
                        }
                    }
                    catch
                    {
                        lab_RRU_Connect_Info.Text = "连接失败";
                        lab_RRU_Connect_Info.BackColor = System.Drawing.Color.Red;
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());//最好做日志记录 log
            }

        }

        private void btn_Query_Click(object sender, EventArgs e)
        {

            string IPQueryCommand = "cat /proc/net/arp";
            string IPQyeryResult1 = "";

            List<string> CommandList = new List<string>() { };

            for (int i = 0; i < 7; i++)//0
            {
                //richTextBox参数8_SP0 Alarm status
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/rx_los", i.ToString()));
                /*告警状态*/
            }
            for (int i = 0; i < 7; i++)//1
            {   //richTextBox参数9_SP0  
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/diagnostics_and_control/RX_Power", i.ToString()));/*接收功率*/

            }
            for (int i = 0; i < 7; i++)//2
            {   //richTextBox参数10_SP0 Alarm status
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/diagnostics_and_control/TX_Power", i.ToString()));/*发射功率*/
            }
            for (int i = 0; i < 7; i++)//3
            {   //richTextBox参数11_SP0 Alarm status
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/diagnostics_and_control/AW_Thresholds", i.ToString())); /*告警门限*/
            }

            for (int i = 0; i < 7; i++)//4
            {    //richTextBox参数1_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/base_id/BR_Nominal", i.ToString())); /*SFP支持最高速率*/
            }
            for (int i = 0; i < 7; i++)//5
            {   //richTextBox参数2_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/base_id/Length_SMF_km", i.ToString())); /*SFP支持拉远长度*/
            }
            for (int i = 0; i < 7; i++)//6
            {   //richTextBox参数3_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/base_id/Wavelength", i.ToString())); /*SFP波长*/
            }
            for (int i = 0; i < 7; i++)//7
            {
                //richTextBox参数4_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/base_id/Vendor_name", i.ToString())); /*供应商名称*/
            }
            for (int i = 0; i < 7; i++)//8
            {   //richTextBox参数5_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/base_id/Vendor_PN", i.ToString())); /*供应商模型*/
            }
            for (int i = 0; i < 7; i++)//9
            {   //richTextBox参数6_SP0
                CommandList.Add(string.Format("cat /sys/class/sfp/sfp_0_{0}/extended_id/Vendor_SN", i.ToString())); /*SFP系列号*/
            }



            if (lab_ConnectINfo_hide.Text == "FSMF")
            {
                if (ssh_Client != null && ssh_Client.IsConnected)
                {
                    IPQyeryResult1 += GetSSHClientResult_CMD(IPQueryCommand);//GetSSHClientResult(ssh_Client.RunCommand(IPQueryCommand));
                    richText_1.Text = IPQyeryResult1;


                    // 4 5 6 7 8 9 
                    // 1 2 3 4 5 6 
                    for (int i = 0; i < 6; i++)
                    {
                        for (int j = 4; j <= 9; j++)
                        {
                            string IPQyeryResult = CommandList[i + 7 * j].ToString() + "\n";
                            string strResult = string.Empty;
                            strResult = GetSSHClientResult_CMD(CommandList[i + 7 * j].ToString());
                            IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                            RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数" + (j - 3).ToString() + "_SP" + i.ToString());
                            richTextbox.Text = IPQyeryResult; // j-3 是从 1取到 1 到 6 strResult ==>IPQyeryResult
                            //richTextBox参数_SP 1至6
                        }
                    }

                    for (int i = 0; i < 6; i++)
                    {
                        //cat /sys/class/sfp/sfp_0_{0}/rx_los  命令编号 0
                        string IPQyeryResult = CommandList[i + 7 * 0].ToString() + "\n";
                        string strResult = string.Empty;
                        strResult = GetSSHClientResult_CMD(CommandList[i + 7 * 0].ToString());
                        IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", ""));
                        RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数8_SP" + i.ToString());
                        richTextbox.Text = strResult;

                        RichTextBox richTextbox_indicator = (RichTextBox)findControl(this, "richTextBox参数7_SP" + i.ToString());
                        if (IPQyeryResult.Trim() == "0")
                        { richTextbox_indicator.BackColor = System.Drawing.Color.Green; }
                        if (IPQyeryResult.Trim() == "1")
                        { richTextbox_indicator.BackColor = System.Drawing.Color.Red; }
                        /*颜色*/

                    }

                    for (int i = 0; i < 6; i++)
                    {
                        //SFP接收功率 diagnostics_and_control/RX_Power  
                        string IPQyeryResult = CommandList[i + 7 * 1].ToString() + "\n";
                        //IPQyeryResult3 += exec.RunCommand(CommandList[i + 7].ToString());
                        string strResult = string.Empty;
                        strResult = GetSSHClientResult_CMD(CommandList[i + 7 * 1].ToString());
                        IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                        RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数9_SP" + i.ToString());
                        richTextbox.Text = IPQyeryResult; //
                    }

                    for (int i = 0; i < 6; i++)
                    {
                        //SFP发射功率 diagnostics_and_control/TX_Power  
                        string IPQyeryResult = CommandList[i + 7 * 2].ToString() + "\n";
                        string strResult = string.Empty;
                        strResult = GetSSHClientResult_CMD(CommandList[i + 7 * 2].ToString());
                        IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                        RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数10_SP" + i.ToString());
                        richTextbox.Text = IPQyeryResult;
                    }
                    for (int i = 0; i < 6; i++)
                    {
                        string strResult = string.Empty;
                        strResult = GetSSHClientResult_CMD(CommandList[i + 7 * 3].ToString());
                        string strHex = GetHexStringEx(strResult);

                        RichTextBox richTextbox_14 = (RichTextBox)findControl(this, "richTextBox参数14_SP" + i.ToString());
                        RichTextBox richTextbox_12 = (RichTextBox)findControl(this, "richTextBox参数12_SP" + i.ToString());
                        richTextbox_14.Text = "";
                        richTextbox_12.Text = "";
                        if (SFPSpec != null)
                        {
                            /*格式变化  1202~12589 */
                            if (SFPSpec[2] != null && SFPSpec[3] != null)
                            {
                                richTextbox_14.Text = SFPSpec[3] + "~" + SFPSpec[2];
                            }
                            if (SFPSpec[6] != null && SFPSpec[7] != null)
                            {
                                richTextbox_12.Text = SFPSpec[7] + "~" + SFPSpec[6];
                            }

                        }
                    }


                }
                else
                {
                    MessageBox.Show("未连接SSH服务器,请先连接");
                }
            }


            if (lab_ConnectINfo_hide.Text == "FSIH")
            {
                if (ssh_Client == null)
                {
                    ssh_Client = new Renci.SshNet.SshClient(Ip, User, PWD);
                    ssh_Client.Connect();
                }


                if (ssh_Client != null && ssh_Client.IsConnected)
                {
                    IPQyeryResult1 += GetSSHClientResult(ssh_Client.RunCommand(IPQueryCommand));//GetSSHClientResult_CMD(IPQueryCommand);
                    richText_1.Text = IPQyeryResult1;



                    shell.Shell("ssh toor4nsn@192.168.253.18");         //执行获取命令   
                    //获取返回结果 
                    Thread.Sleep(1000);
                    string info = shell.GetAllString();

                    if (info.IndexOf("Are you sure you want to continue connecting (yes/no)") > 0)
                    {
                        shell.Shell("yes");
                    }
                    Thread.Sleep(1000);
                    shell.Shell("oZPS0POrRieRtu");                      //执行获取命令  
                }


                // 4 5 6 7 8 9 
                // 1 2 3 4 5 6 

                for (int i = 0; i < 6; i++)
                {
                    for (int j = 4; j <= 9; j++)
                    {
                        string IPQyeryResult = CommandList[i + 7 * j].ToString() + "\n";
                        string strResult = string.Empty;
                        strResult = GetSSHShellResult(ref  shell, CommandList[i + 7 * j].ToString());
                        IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                        RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数" + (j - 3).ToString() + "_SP" + i.ToString());
                        richTextbox.Text = IPQyeryResult; // j-3 是从 1取到 1 到 6 strResult ==>IPQyeryResult

                    }
                }



                for (int i = 0; i < 6; i++)
                {
                    //cat /sys/class/sfp/sfp_0_{0}/rx_los  命令编号 0
                    string IPQyeryResult = CommandList[i + 7 * 0].ToString() + "\n";
                    string strResult = string.Empty;
                    strResult = GetSSHShellResult(ref shell, CommandList[i + 7 * 0].ToString());
                    IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", ""));
                    RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数8_SP" + i.ToString());
                    richTextbox.Text = strResult;

                    RichTextBox richTextbox_indicator = (RichTextBox)findControl(this, "richTextBox参数7_SP" + i.ToString());
                    if (IPQyeryResult.Trim() == "0")
                    { richTextbox_indicator.BackColor = System.Drawing.Color.Green; }
                    if (IPQyeryResult.Trim() == "1")
                    { richTextbox_indicator.BackColor = System.Drawing.Color.Red; }
                    /*颜色*/
                }

                for (int i = 0; i < 6; i++)
                {
                    //SFP接收功率 diagnostics_and_control/RX_Power  
                    string IPQyeryResult = CommandList[i + 7 * 1].ToString() + "\n";

                    string strResult = string.Empty;
                    strResult = GetSSHShellResult(ref shell, CommandList[i + 7 * 1].ToString());
                    IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                    RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数9_SP" + i.ToString());
                    richTextbox.Text = IPQyeryResult;
                }

                for (int i = 0; i < 6; i++)
                {
                    //SFP接收功率 diagnostics_and_control/TX_Power  
                    string IPQyeryResult = CommandList[i + 7 * 2].ToString() + "\n";
                    string strResult = string.Empty;
                    strResult = GetSSHShellResult(ref shell, CommandList[i + 7 * 2].ToString());
                    IPQyeryResult = CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";
                    RichTextBox richTextbox = (RichTextBox)findControl(this, "richTextBox参数10_SP" + i.ToString());
                    richTextbox.Text = IPQyeryResult;
                }
                for (int i = 0; i < 6; i++)
                {
                    string strResult = string.Empty;
                    strResult = GetSSHShellResult(ref shell, CommandList[i + 7 * 3].ToString());
                    string strHex = GetHexStringEx(strResult);

                    RichTextBox richTextbox_14 = (RichTextBox)findControl(this, "richTextBox参数14_SP" + i.ToString());
                    RichTextBox richTextbox_12 = (RichTextBox)findControl(this, "richTextBox参数12_SP" + i.ToString());
                    richTextbox_14.Text = "";
                    richTextbox_12.Text = "";

                    if (SFPSpec != null)
                    {
                        /*格式变化  1202~12589 */
                        if (SFPSpec[2] != null && SFPSpec[3] != null)
                        {
                            //RichTextBox richTextbox_14 = (RichTextBox)findControl(this, "richTextBox参数14_SP" + i.ToString());
                            richTextbox_14.Text = SFPSpec[3] + "~" + SFPSpec[2];
                        }
                        if (SFPSpec[6] != null && SFPSpec[7] != null)
                        {
                            //RichTextBox richTextbox_12 = (RichTextBox)findControl(this, "richTextBox参数12_SP" + i.ToString());
                            richTextbox_12.Text = SFPSpec[7] + "~" + SFPSpec[6];
                        }

                    }
                }


                shell.Close();


            }


            if (ConnectionType_RRU.Text == "TELNET")
            {

                this.tabControl1.TabPages.Clear();
                this.tabControl1.TabPages.Add(tp_Telnet);


                if (telnet != null && telnet.IsConnected())
                {
                    telnet.Connect();
                }
                else
                {
                    MessageBox.Show("RRU TELNET查询失败");
                    return;
                }

                List<Tamir.SharpSsh.SFP_RealTimeInfo> RealTime_M_List = new List<Tamir.SharpSsh.SFP_RealTimeInfo>();

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 0");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 4));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 1");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 3));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 2");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 3));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 3");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 3));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 4");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 3));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -m 5");
                RealTime_M_List.Add(shell.GetRealTimeModel(telnet.SessionLog, 3));

                List<Tamir.SharpSsh.SFP_BaseInfo> Base_M_List = new List<Tamir.SharpSsh.SFP_BaseInfo>();

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 0");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 1");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 2");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 3");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));


                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 4");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));

                telnet.ClearFullLog();
                telnet.SendMessage("sfp -i 5");
                Thread.Sleep(500);
                Base_M_List.Add(shell.GetBaseInfoModel(telnet.SessionLog, 0));

                string ErrorHint = "not present!";
                for (int i = 0; i < 6; i++)
                {
                    RichTextBox richTextbox_1 = (RichTextBox)findControl(this, "richTextBox_RRU参数1_SP" + i.ToString());

                    if (Base_M_List[i] == null)
                        richTextbox_1.Text = ErrorHint;
                    else
                        richTextbox_1.Text = Base_M_List[i].Nominal_Bit_Rate;//RealTime_M_List[i].Bias Base_M_List[i].Nominal_Bit_Rate;

                    RichTextBox richTextbox_2 = (RichTextBox)findControl(this, "richTextBox_RRU参数2_SP" + i.ToString());
                    if (Base_M_List[i] == null)
                        richTextbox_2.Text = ErrorHint;
                    else
                        richTextbox_2.Text = Base_M_List[i].Link_length_supported;

                    RichTextBox richTextbox_3 = (RichTextBox)findControl(this, "richTextBox_RRU参数3_SP" + i.ToString());
                    if (Base_M_List[i] == null)
                        richTextbox_3.Text = ErrorHint;
                    else
                        richTextbox_3.Text = Base_M_List[i].Wave_length;

                    RichTextBox richTextbox_4 = (RichTextBox)findControl(this, "richTextBox_RRU参数4_SP" + i.ToString());
                    if (Base_M_List[i] == null)
                        richTextbox_4.Text = ErrorHint;
                    else
                        richTextbox_4.Text = Base_M_List[i].Vendor_Name;

                    RichTextBox richTextbox_5 = (RichTextBox)findControl(this, "richTextBox_RRU参数5_SP" + i.ToString());
                    if (Base_M_List[i] == null)
                        richTextbox_5.Text = ErrorHint;
                    else
                        richTextbox_5.Text = Base_M_List[i].Vendor_part_number;

                    RichTextBox richTextbox_6 = (RichTextBox)findControl(this, "richTextBox_RRU参数6_SP" + i.ToString());
                    if (Base_M_List[i] == null)
                        richTextbox_6.Text = ErrorHint;
                    else
                        richTextbox_6.Text = Base_M_List[i].Vendor_serial_number;

                    RichTextBox richTextbox_9 = (RichTextBox)findControl(this, "richTextBox_RRU参数9_SP" + i.ToString());
                    if (RealTime_M_List[i] == null)
                        richTextbox_9.Text = ErrorHint;
                    else
                        richTextbox_9.Text = RealTime_M_List[i].RX_Laser_Power;

                    RichTextBox richTextbox_10 = (RichTextBox)findControl(this, "richTextBox_RRU参数10_SP" + i.ToString());
                    if (RealTime_M_List[i] == null)
                        richTextbox_10.Text = ErrorHint;
                    else
                        richTextbox_10.Text = RealTime_M_List[i].TX_Laser_Power;
                }
                telnet.Disconnect();
            }



            if (ConnectionType_RRU.Text == "SSH")
            {
                this.tabControl1.TabPages.Clear();
                this.tabControl1.TabPages.Add(tp_FSMF);
                this.tabControl1.TabPages.Add(tp_FSIH);
                this.tabControl1.TabPages.Add(tp_TPT);

                QueryHandle_SSHCient(txt_ip_rru.Text.Trim());
                QueryTPT_SSHCient(txt_ip_rru.Text.Trim());

            }
            if (ConnectionType_RRU.Text == "FBIH1/FBBA1")
            {
                this.tabControl1.TabPages.Clear();
                this.tabControl1.TabPages.Add(tp_FSMF);
                this.tabControl1.TabPages.Add(tp_FSIH);
                this.tabControl1.TabPages.Add(tp_TPT);

                if (shell.OpenShell(txt_ip_rru.Text.Trim(), txt_user_rru.Text.Trim(), txt_pwd_rru.Text.Trim(), 22))
                {
                    QueryHandle_SSHCient("192.168.253.19");
                    QueryTPT_SSHCient("192.168.253.19");
                }
            }
            if (ConnectionType_RRU.Text == "FBIH2/FBBA2")
            {
                this.tabControl1.TabPages.Clear();
                this.tabControl1.TabPages.Add(tp_FSMF);
                this.tabControl1.TabPages.Add(tp_FSIH);
                this.tabControl1.TabPages.Add(tp_TPT);

                if (shell.OpenShell(txt_ip_rru.Text.Trim(), txt_user_rru.Text.Trim(), txt_pwd_rru.Text.Trim(), 22))
                {
                    QueryHandle_SSHCient("192.168.253.20");
                    QueryTPT_SSHCient("192.168.253.20");
                }
            }


            MessageBox.Show(lab_ConnectINfo_hide.Text + "查询完成");
        }



        public void QueryHandle(string SSHIP)
        {
            /*控件清空*/
            rtxt_FSMF.Text = "";
            rtxt_FSIH.Text = "";
            rtxt_FSMF.BackColor = System.Drawing.Color.White;
            rtxt_FSIH.BackColor = System.Drawing.Color.White;


            string ErrMsg = "";
            List<DDAL_SFP> DDAL_SFPLIST = new List<DDAL_SFP>();
            List<DDAL_SFP_DEV_LOCAL_RADIO_IF> DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new List<DDAL_SFP_DEV_LOCAL_RADIO_IF>();

            shell = new Tamir.SharpSsh.ShellHelp();
            if (shell.OpenShell(txt_IP.Text.Trim(), txt_user.Text.Trim(), txt_pwd.Text.Trim(), 22))
            {

                try
                {
                    string result = RRU_QUERY(ref shell); //步骤处理

                    if (result.IndexOf("No such file or directory") == -1)
                    {

                        DDAL_SFPLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFPmodelList(result);
                        DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFP_DEV_LOCAL_RADIO_IF_modelList(result);
                        BindText(DDAL_SFPLIST, DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, "FSMF");
                    }
                    else
                    {
                        ErrMsg = "文件操作失败";
                        rtxt_FSMF.Text = ErrMsg;
                        rtxt_FSMF.BackColor = System.Drawing.Color.Red;

                    }
                }
                catch
                {
                    ErrMsg = "文件操作失败";
                    rtxt_FSMF.Text = ErrMsg;//单独的提示
                    rtxt_FSMF.BackColor = System.Drawing.Color.Red;
                }

  

                shell.Shell(string.Format("ssh toor4nsn@{0}", SSHIP));
                try
                {
                    if (shell.SessionLog.IndexOf("Connection refused") > -1 || shell.SessionLog.IndexOf("Connection timed out") > -1)
                    {
                        lab_RRU_Connect_Info.Text = SSHIP + "连接失败";

                    }
                    else
                    {
 
                        Thread.Sleep(1000);
                        string info = shell.SessionLog;
                        if (info.IndexOf("Are you sure you want to continue connecting (yes/no)") > 0)
                        {
                            shell.Shell("yes");
                        }
                        Thread.Sleep(1000);
                        shell.Shell("oZPS0POrRieRtu");


                        string result2 = RRU_QUERY(ref shell);
                        if (result2.IndexOf("No such file or directory") == -1)
                        {
                            DDAL_SFPLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFPmodelList(result2);
                            DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFP_DEV_LOCAL_RADIO_IF_modelList(result2);
                            BindText(DDAL_SFPLIST, DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, "FSIH");
                        }
                        else
                        {
                            ErrMsg = "文件操作失败";
                            rtxt_FSIH.Text = ErrMsg;//单独的提示
                            rtxt_FSIH.BackColor = System.Drawing.Color.Red;
                        }
                    }
                }
                catch
                {
                    ErrMsg = "文件操作失败";
                    rtxt_FSIH.Text = ErrMsg;//单独的提示
                    rtxt_FSIH.BackColor = System.Drawing.Color.Red;
                }

            }
            else
            {
                lab_RRU_Connect_Info.Text = txt_IP.Text + "连接失败";
            }
        }
        /// <summary>
        /// 拓扑图
        /// </summary>
        public void QueryTPT(string SSHIP)
        {
            string ErrMsg = "";
            string RXstate = string.Empty;
            string err_cnt = "";
            string err_cnt_tot = "";

            try
            {

                if (shell.OpenShell(txt_ip_rru.Text.Trim(), txt_user_rru.Text.Trim(), txt_pwd_rru.Text.Trim(), 22))
                {
                    Thread.Sleep(1000);
                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_sm/state");
                    RXstate = shell.SessionLog;
                    txt_FSMF_RXSTATE.Text = CommonClass.StringHander.Common.GetHexString(RXstate);//RXstate;// CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";

                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt");
                    err_cnt = shell.SessionLog;
                    txt_FSMF_err_cnt.Text = CommonClass.StringHander.Common.GetHexString(err_cnt);//err_cnt;

                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt_tot");

                    //GetSSHClientResult(,);

                    err_cnt_tot = shell.SessionLog;
                    txt_FSMF_err_cnt_tot.Text = CommonClass.StringHander.Common.GetHexString(err_cnt_tot);//err_cnt_tot;

                }
                else
                {
                    ErrMsg = "误码信息查询失败 FSMF";
                    Lab_FSMF_TPT.Text = ErrMsg;
                }
            }
            catch
            {
                ErrMsg = "误码信息查询失败 FSMF";
                Lab_FSMF_TPT.Text = ErrMsg;
            }

            try
            {
                shell.Shell(string.Format("ssh toor4nsn@{0}", SSHIP));
                if (shell.SessionLog.IndexOf("Connection refused") > -1 || shell.SessionLog.IndexOf("Connection timed out") > -1)
                {
                    ErrMsg = "误码信息查询失败 FSIH";
                    Lab_FSIH_TPT.Text = ErrMsg;
                }
                else
                {

                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_sm/state");
                    RXstate = shell.SessionLog;
                    txt_FSIH_RXSTATE.Text = CommonClass.StringHander.Common.GetHexString(RXstate);//RXstate;

                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt");
                    err_cnt = shell.SessionLog;
                    txt_FSIH_err_cnt.Text = CommonClass.StringHander.Common.GetHexString(err_cnt);//err_cnt;

                    shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt_tot");
                    err_cnt_tot = shell.SessionLog;
                    txt_FSIH_err_cnt_tot.Text = CommonClass.StringHander.Common.GetHexString(err_cnt_tot);//err_cnt_tot;

                    if (RXstate.Trim() == "0x3")
                    {
                        lab_lineFSIH.ForeColor = System.Drawing.Color.Green;
                        this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_G_IMAGE;
                    }
                    else
                        if (RXstate.Trim() == "0x0")
                        {
                            lab_lineFSIH.ForeColor = System.Drawing.Color.Red;
                            this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_R_IMAGE;
                        }
                        else
                        {
                            lab_lineFSIH.ForeColor = System.Drawing.Color.Gray;
                            this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_R_IMAGE;
                        }
                }
            }
            catch
            {
                ErrMsg = "误码信息查询失败 FSIH";
                Lab_FSIH_TPT.Text = ErrMsg;
            }
        }
        /// <summary>
        /// RRU_QUERY 方法重写
        /// </summary>
        /// <param name="_shell"></param>
        /// <returns></returns>
        private string RRU_QUERY(ref Tamir.SharpSsh.ShellHelp _shell)
        {
            _shell.Shell("cd /flash");
            _shell.Shell("cp -f sfp_tool.tar /");
            _shell.Shell("cd .. ");
            _shell.Shell("tar xvf sfp_tool.tar");
            Thread.Sleep(1000);
            _shell.Shell("chmod +x sfp_tool");
            _shell.Shell("./sfp_tool -v");
            return _shell.SessionLog;
        }

        private void BindText(List<DDAL_SFP> _DDAL_SFPLIST, List<DDAL_SFP_DEV_LOCAL_RADIO_IF> _DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, string QueryType)
        {
            //txt_FSMF_DDAL_参数1_SFP_0  FSMF FSIH
            /*
             * 1---光口速率  Vendor --厂商
             */
            for (int i = 0; i <= 5; i++)
            {

                if (_DDAL_SFPLIST[i] != null)
                {
                    //光口速率 Bitrate
                    RichTextBox text1 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数1_SFP_" + i.ToString());
                    text1.Text = _DDAL_SFPLIST[i].Bitrate;
                }
                if (_DDAL_SFPLIST[i] != null)
                {
                    //传输距离 Connector
                    RichTextBox text2 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数2_SFP_" + i.ToString());
                    text2.Text = _DDAL_SFPLIST[i].Connector;
                }
                if (_DDAL_SFPLIST[i] != null)
                {   //波长  Wavelength
                    RichTextBox text3 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数3_SFP_" + i.ToString());
                    text3.Text = _DDAL_SFPLIST[i].Wavelength;
                }
                if (_DDAL_SFPLIST[i] != null)
                {   //供应商名称 Vendor
                    RichTextBox text4 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数4_SFP_" + i.ToString());
                    text4.Text = _DDAL_SFPLIST[i].Vendor;
                }

                if (_DDAL_SFPLIST[i] != null)
                {
                    RichTextBox text5 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数5_SFP_" + i.ToString());
                    text5.Text = _DDAL_SFPLIST[i].Part_number;
                }
                if (_DDAL_SFPLIST[i] != null)
                {
                    RichTextBox text5 = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数6_SFP_" + i.ToString());
                    text5.Text = _DDAL_SFPLIST[i].Serial;
                }

                if (_DDAL_SFPLIST[i] != null)
                {    //Temperature
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数7_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Temperature;
                }
                if (_DDAL_SFPLIST[i] != null)
                {    //
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数8_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Voltage;
                }
                if (_DDAL_SFPLIST[i] != null)
                {    //
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数9_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Input_power;
                }


                if (_DDAL_SFPLIST[i] != null)
                {    //
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数10_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Input_power_in_dbm;
                }

                if (_DDAL_SFPLIST[i] != null)
                {    //
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数11_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Output_power;
                }
                if (_DDAL_SFPLIST[i] != null)
                {    //
                    RichTextBox text = (RichTextBox)new SSHTool.Common.CommonClass().findControl(this, "txt_" + QueryType + "_DDAL_参数12_SFP_" + i.ToString());
                    text.Text = _DDAL_SFPLIST[i].Output_power_in_dbm;
                }
            }

        }



        #region RRU_SSH的处理 new
        /// <summary>
        /// 查询处理
        /// </summary>
        public void QueryHandle_SSHCient(string SSHIP)
        {
            /*控件清空*/
            rtxt_FSMF.Text = "";
            rtxt_FSIH.Text = "";
            rtxt_FSMF.BackColor = System.Drawing.Color.White;
            rtxt_FSIH.BackColor = System.Drawing.Color.White;


            string ErrMsg = "";
            List<DDAL_SFP> DDAL_SFPLIST = new List<DDAL_SFP>();
            List<DDAL_SFP_DEV_LOCAL_RADIO_IF> DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new List<DDAL_SFP_DEV_LOCAL_RADIO_IF>();


            ssh_Client = new Renci.SshNet.SshClient(txt_ip_rru.Text.Trim(), txt_user_rru.Text.Trim(), txt_pwd_rru.Text.Trim());
            ssh_Client.Connect();
            //if (shell.OpenShell(txt_IP.Text.Trim(), txt_user.Text.Trim(), txt_pwd.Text.Trim(), 22));

            if (ssh_Client.IsConnected)
            {
                #region  /* RRU_FSMF*/
                try
                {

                    string result = GetSSHClientResult_CMD(ssh_Client, "chmod +x /sfp_tool;/sfp_tool -v;");

                    if (result.IndexOf("No such file or directory") == -1)
                    {

                        DDAL_SFPLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFPmodelList(result);
                        DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFP_DEV_LOCAL_RADIO_IF_modelList(result);
                        BindText(DDAL_SFPLIST, DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, "FSMF");
                    }
                    else
                    {
                        ErrMsg = "文件操作失败";
                        rtxt_FSMF.Text = ErrMsg;
                        rtxt_FSMF.BackColor = System.Drawing.Color.Red;

                    }
                }
                catch
                {
                    ErrMsg = "文件操作失败";
                    rtxt_FSMF.Text = ErrMsg;//单独的提示
                    rtxt_FSMF.BackColor = System.Drawing.Color.Red;
                }

                #endregion
                #region /* RRU_FSIH*/
                //shell.Shell(string.Format("ssh toor4nsn@{0}", SSHIP));
                //try
                //{
                //    if (shell.SessionLog.IndexOf("Connection refused") > -1 || shell.SessionLog.IndexOf("Connection timed out") > -1)
                //    {
                //        lab_RRU_Connect_Info.Text = SSHIP + "连接失败";
                //    }
                //    else
                //    {
                //        #region SSH 登陆 方法
                //        Thread.Sleep(1000);
                //        string info = shell.SessionLog;
                //        if (info.IndexOf("Are you sure you want to continue connecting (yes/no)") > 0)
                //        {
                //            shell.Shell("yes");
                //        }
                //        Thread.Sleep(1000);
                //        shell.Shell("oZPS0POrRieRtu");
                //        #endregion

                //        string result2 = RRU_QUERY(ref shell);
                //        if (result2.IndexOf("No such file or directory") == -1)
                //        {
                //            DDAL_SFPLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFPmodelList(result2);
                //            DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFP_DEV_LOCAL_RADIO_IF_modelList(result2);
                //            BindText(DDAL_SFPLIST, DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, "FSIH");
                //        }
                //        else
                //        {
                //            ErrMsg = "文件操作失败";
                //            rtxt_FSIH.Text = ErrMsg;//单独的提示
                //            rtxt_FSIH.BackColor = System.Drawing.Color.Red;
                //        }
                //    }
                // }
                // catch
                // {
                //     ErrMsg = "文件操作失败";
                //     rtxt_FSIH.Text = ErrMsg;//单独的提示
                //     rtxt_FSIH.BackColor = System.Drawing.Color.Red;
                // }
                #endregion
            }
            else
            {
                lab_RRU_Connect_Info.Text = txt_IP.Text + "连接失败";
            }
        }
        #region /* 拓扑图*/

        public void QueryTPT_SSHCient(string SSHIP)
        {
            string ErrMsg = "";
            string RXstate = string.Empty;
            string err_cnt = "";
            string err_cnt_tot = "";

            try
            {
                ssh_Client.Connect();
                if (ssh_Client.IsConnected)
                {
                    Thread.Sleep(1000);
                    RXstate = GetSSHClientResult_CMD("cat /sys/class/flexi/rp3_01_link0/rx_sm/state");
                    txt_FSMF_RXSTATE.Text = CommonClass.StringHander.Common.GetHexString(RXstate);//RXstate;// CommonClass.StringHander.Common.GetHexString(strResult.Replace("\n\0", "")) + "\n";


                    err_cnt = GetSSHClientResult_CMD("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt");
                    txt_FSMF_err_cnt.Text = CommonClass.StringHander.Common.GetHexString(err_cnt);//err_cnt;



                    err_cnt_tot = GetSSHClientResult_CMD("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt_tot");
                    txt_FSMF_err_cnt_tot.Text = CommonClass.StringHander.Common.GetHexString(err_cnt_tot);//err_cnt_tot;

                }
                else
                {
                    ErrMsg = "误码信息查询失败 FSMF";
                    Lab_FSMF_TPT.Text = ErrMsg;
                }
            }
            catch
            {
                ErrMsg = "误码信息查询失败 FSMF";
                Lab_FSMF_TPT.Text = ErrMsg;
            }
        #endregion
            #region FSIH 的拓扑查询
            //try
            //{
            //    shell.Shell(string.Format("ssh toor4nsn@{0}", SSHIP));
            //    if (shell.SessionLog.IndexOf("Connection refused") > -1 || shell.SessionLog.IndexOf("Connection timed out") > -1)
            //    {
            //        ErrMsg = "误码信息查询失败 FSIH";
            //        Lab_FSIH_TPT.Text = ErrMsg;
            //    }
            //    else
            //    {

            //        shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_sm/state");
            //        RXstate = shell.SessionLog;
            //        txt_FSIH_RXSTATE.Text = CommonClass.StringHander.Common.GetHexString(RXstate);//RXstate;

            //        shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt");
            //        err_cnt = shell.SessionLog;
            //        txt_FSIH_err_cnt.Text = CommonClass.StringHander.Common.GetHexString(err_cnt);//err_cnt;

            //        shell.Shell("cat /sys/class/flexi/rp3_01_link0/rx_lcv/err_cnt_tot");
            //        err_cnt_tot = shell.SessionLog;
            //        txt_FSIH_err_cnt_tot.Text = CommonClass.StringHander.Common.GetHexString(err_cnt_tot);//err_cnt_tot;

            //        if (RXstate.Trim() == "0x3")
            //        {
            //            lab_lineFSIH.ForeColor = System.Drawing.Color.Green;
            //            this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_G_IMAGE;
            //        }
            //        else
            //            if (RXstate.Trim() == "0x0")
            //            {
            //                lab_lineFSIH.ForeColor = System.Drawing.Color.Red;
            //                this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_R_IMAGE;
            //            }
            //            else
            //            {
            //                lab_lineFSIH.ForeColor = System.Drawing.Color.Gray;
            //                this.pictureBox3.Image = global::SSHTool.Properties.Resources.RRU_R_IMAGE;
            //            }
            //    }
            //}
            //catch
            //{
            //    ErrMsg = "误码信息查询失败 FSIH";
            //    Lab_FSIH_TPT.Text = ErrMsg;
            //}
            #endregion
        }
        /// <summary>
        /// RRU_QUERY 方法重写
        /// </summary>
        /// <param name="_shell"></param>
        /// <returns></returns>
        private string RRU_QUERY_SSHCient(ref Renci.SshNet.SshClient _sshClient)
        {
            //_sshClient.RunCommand("cd /flash");
            //_sshClient.RunCommand("cp -f sfp_tool.tar /");
            //_sshClient.RunCommand("cd .. ");
            //_sshClient.RunCommand("tar xvf sfp_tool.tar");
            //Thread.Sleep(1000);
            //_sshClient.RunCommand("chmod +x sfp_tool");

            _sshClient.RunCommand("cd /flash");
            _sshClient.RunCommand("cp -f /flash/sfp_tool /");
            //_sshClient.RunCommand("cd .. ");

            Thread.Sleep(1000);
            _sshClient.RunCommand("chmod +x /sfp_tool");
            string SessionLog = GetSSHClientResult_CMD("/sfp_tool -v");
            return SessionLog;
        }


        #endregion


        #region 查询结果处理
        public string GetSSHShellResult(ref Tamir.SharpSsh.ShellHelp _shell, string Cmd)
        {
            try
            {
                _shell.Shell(Cmd);

                if (_shell.SessionLog.Trim() != "\r\n")
                {
                    return _shell.SessionLog.Trim();
                }
                else
                {
                    return "SFP不存在";
                }
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }
        #endregion

        #region 达到告警门限提示
        public string GetSFP_Rec_Result(string str)
        {
            string ret = string.Empty;
            int num = 0;
            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    num = Convert.ToInt32(str, 16);//更换

                    if (num <= RX_Low_Alarm)
                    {
                        ret = str + string.Format("(达到RX Power Low Alarm:{0},请处理！)", num.ToString());
                    }
                    else if (num >= RX_High_Alarm)
                    {
                        ret = str + string.Format("(达到RX Power High Alarm:{0},请处理！)", num.ToString());
                    }
                    else if (num < RX_High_Alarm && num > RX_Low_Alarm)
                    {
                        ret = str + string.Format("(正常,RX范围{0}-{1},单位:0.1uw)", RX_Low_Alarm.ToString(), RX_High_Alarm.ToString());
                    }
                    if (num <= RX_Low_Warning)
                    {
                        ret = str + string.Format("(达到RX Power Low Warning:{0},请处理！)", num.ToString());
                    }
                    else if (num >= RX_High_Warning)
                    {
                        ret = str + string.Format("(达到RX Power High Alarm:{0},请处理！)", num.ToString());
                    }
                    else if (num < RX_High_Warning && num > RX_Low_Warning)
                    {
                        ret = str + string.Format("(正常,RX范围{0}-{1},单位:0.1uw)", RX_Low_Warning.ToString(), RX_High_Warning.ToString());
                    }

                }
                catch (Exception)
                {
                }

            }
            return ret;
        }

        public string GetSFP_Send_Result(string str)
        {
            string ret = string.Empty;
            int num = 0;
            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    num = Convert.ToInt32(str, 16);
                    if (num <= TX_Low_Alarm)
                    {
                        ret = str + string.Format("(达到TX Power Low Alarm:{0},请处理！)", num.ToString());
                    }
                    else if (num >= TX_High_Alarm)
                    {
                        ret = str + string.Format("(达到TX Power High Alarm:{0},请处理！)", num.ToString());
                    }
                    else if (num < TX_High_Alarm && num > TX_Low_Alarm)
                    {
                        ret = str + string.Format("(正常,TX范围{0}-{1},单位:0.1uw)", TX_Low_Alarm.ToString(), TX_High_Alarm.ToString());
                    }

                    if (num <= TX_Low_Warning)
                    {
                        ret = str + string.Format("(达到TX Power Low Warning:{0},请处理！)", num.ToString());
                    }
                    else if (num >= TX_High_Warning)
                    {
                        ret = str + string.Format("(达到TX Power High Warning:{0},请处理！)", num.ToString());
                    }
                    else if (num < TX_Low_Warning && num > TX_High_Warning)
                    {
                        ret = str + string.Format("(正常,TX范围{0}-{1},单位:0.1uw)", TX_Low_Warning.ToString(), TX_High_Warning.ToString());
                    }

                }
                catch (Exception)
                {
                }

            }
            return ret;
        }
        #endregion

        #region 取告警门限值
        private string GetHexStringEx(string value)
        {
            SFPSpec = new string[8];
            SFPSpecLength = new int[8];
            string ret = string.Empty;
            char[] ch = { ' ' };
            value = value.Replace("0x", "");
            string[] str = value.Split(ch, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < str.Length; i += 2)
            {
                try
                {
                    int num = Convert.ToInt32(str[i] + str[i + 1], 16);
                    if (i == 24)//TX Power High Alarm 
                    {
                        SFPSpec[0] = num.ToString();
                        SFPSpecLength[0] = ret.Length;
                        TX_High_Alarm = int.Parse(num.ToString());
                    }
                    if (i == 26)
                    {
                        SFPSpec[1] = num.ToString();
                        SFPSpecLength[1] = ret.Length;
                        TX_Low_Alarm = int.Parse(num.ToString());
                    }
                    if (i == 28)
                    {
                        SFPSpec[2] = num.ToString();
                        SFPSpecLength[2] = ret.Length;
                        TX_High_Warning = int.Parse(num.ToString());
                    }
                    if (i == 30)
                    {
                        SFPSpec[3] = num.ToString();
                        SFPSpecLength[3] = ret.Length;
                        TX_Low_Warning = int.Parse(num.ToString());
                    }
                    if (i == 32)
                    {
                        SFPSpec[4] = num.ToString();
                        SFPSpecLength[4] = ret.Length;
                        RX_High_Alarm = int.Parse(num.ToString());
                    }
                    if (i == 34)
                    {
                        SFPSpec[5] = num.ToString();
                        SFPSpecLength[5] = ret.Length;
                        RX_Low_Alarm = int.Parse(num.ToString());
                    }
                    if (i == 36)
                    {
                        SFPSpec[6] = num.ToString();
                        SFPSpecLength[6] = ret.Length;
                        RX_High_Warning = int.Parse(num.ToString());
                    }
                    if (i == 38)
                    {
                        SFPSpec[7] = num.ToString();
                        SFPSpecLength[7] = ret.Length;
                        RX_Low_Warning = int.Parse(num.ToString());
                    }
                    ret += num.ToString() + " ";
                }
                catch (Exception e)
                {
                    ret += str[i] + " ";
                }
            }
            return ret;
        }
        #endregion

        #region  告警指标灯
        private void SetSFPFontColor(int oldRichTextLength, RichTextBox RichText)
        {
            System.Drawing.Color[] colors = { System.Drawing.Color.Pink,System.Drawing.Color.Green,
                                                System.Drawing.Color.Gray,System.Drawing.Color.Cyan };

            if (SFPSpec.Length == 4)
            {
                int richTextLenght = RichText.Text.Length;
                for (int i = 0; i < SFPSpec.Length; i++)
                {
                    int index;

                    index = oldRichTextLength + SFPSpecLength[i];


                    if (index != -1)
                    {

                        RichText.Select(index, SFPSpec[i] == null ? 0 : SFPSpec[i].Length);
                        RichText.SelectionBackColor = colors[i];

                    }
                }
            }
        }
        #endregion

        private void MainWindowShow2_Load(object sender, EventArgs e)
        {
            tp_FSMF = this.tabControl1.TabPages["FSMF"];
            tp_FSIH = this.tabControl1.TabPages["FSIH"];
            tp_TPT = this.tabControl1.TabPages["TPT"];
            tp_Telnet = this.tabControl1.TabPages["Telnet"];
        }


        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (!checkBox1.Checked) txt_pwd.PasswordChar = '*'; else txt_pwd.PasswordChar = (char)0;

            if (!checkBox1.Checked) txt_pwd_rru.PasswordChar = '*'; else txt_pwd_rru.PasswordChar = (char)0;
        }



        private System.Windows.Forms.Control findControl(System.Windows.Forms.Control control, string controlName)
        {
            Control c1;
            foreach (Control c in control.Controls)
            {
                if (c.Name == controlName)
                {
                    return c;
                }
                else if (c.Controls.Count > 0)
                {
                    c1 = findControl(c, controlName);
                    if (c1 != null)
                    {
                        return c1;
                    }
                }
            }
            return null;
        }


        private void button1_Click_1(object sender, EventArgs e)
        {
            string x = @"0x5F 0x00 0xD8 0x00 0x55 0x00 0xDD 0x00 0x8C 0xA0 0x75 0x30 0x87 0x28 0x7A 0xA8
                        0x9C 0x40 0x13 0x88 0x88 0xB8 0x1D 0x4C 0x31 0x2D 0x09 0x5F 0x2B 0xD4 0x0B 0xCC
                        0x31 0x2D 0x00 0x9E 0x2B 0xD4 0x01 0x6B";

            GetHexStringEx(x);

            for (int i = 0; i < 6; i++)
            {

                if (SFPSpec != null)
                {
                    if (SFPSpec[0] != null && SFPSpec[1] != null)
                    {
                        RichTextBox richTextbox_11 = (RichTextBox)findControl(this, "richTextBox参数11_SP" + i.ToString());
                        richTextbox_11.Text = "H:" + SFPSpec[0] + "L:" + SFPSpec[1];
                    }
                    if (SFPSpec[2] != null && SFPSpec[3] != null)
                    {
                        RichTextBox richTextbox_12 = (RichTextBox)findControl(this, "richTextBox参数12_SP" + i.ToString());
                        richTextbox_12.Text = "H:" + SFPSpec[2] + "L:" + SFPSpec[3];
                    }
                    if (SFPSpec[4] != null && SFPSpec[5] != null)
                    {
                        RichTextBox richTextbox_13 = (RichTextBox)findControl(this, "richTextBox参数13_SP" + i.ToString());
                        richTextbox_13.Text = "H:" + SFPSpec[4] + "L:" + SFPSpec[5];
                    }
                    if (SFPSpec[6] != null && SFPSpec[7] != null)
                    {
                        RichTextBox richTextbox_14 = (RichTextBox)findControl(this, "richTextBox参数14_SP" + i.ToString());
                        richTextbox_14.Text = "H:" + SFPSpec[6] + "L:" + SFPSpec[7];
                    }
                }
            }
        }

        private void ConnectionType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ConnectionType.Text == "FSMF")
            {
                txt_IP.Text = "10.69.64.209";
                txt_user.Text = "toor4nsn";
                txt_pwd.Text = "oZPS0POrRieRtu";
                btn_Connect.Visible = true;
                lab_ConnectINfo_hide.Text = "FSMF";
            }
            if (ConnectionType.Text == "FSIH")
            {
                txt_IP.Text = "10.56.7.5";
                txt_user.Text = "toor4nsn";
                txt_pwd.Text = "oZPS0POrRieRtu";
                btn_Connect.Visible = true;
                lab_ConnectINfo_hide.Text = "FSIH";
            }
        }

        private void 处理ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void RRU查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RRU_QUERY.RRUQuery1 form1 = new RRU_QUERY.RRUQuery1();
            form1.Show();
        }


        private void ConnectionType_RRU_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ConnectionType_RRU.Text == "TELNET")
            {
                txt_ip_rru.Text = "192.168.253.206";
                txt_user_rru.Text = "toor4nsn";
                txt_pwd_rru.Text = "oZPS0POrRieRtu";
            }
            if (ConnectionType_RRU.Text == "SSH")
            {

                txt_ip_rru.Text = "10.69.66.79";
                txt_user_rru.Text = "toor4nsn";
                txt_pwd_rru.Text = "oZPS0POrRieRtu";
            }

        }


        private void 关于AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SSHTool.Help.About form1 = new SSHTool.Help.About();
            form1.ShowDialog();
        }


        private void 使用说明ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String strFilePath = Application.StartupPath + @"\Help\说明.htm";
            System.Diagnostics.Process.Start("IExplore.exe", strFilePath);
        }

        private void rRU连接文件上传ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SSHTool.RRU_QUERY.FlieUpLoadToLinux x = new RRU_QUERY.FlieUpLoadToLinux();
            x.ShowDialog();

        }



        public string GetSSHClientResult(Renci.SshNet.SshCommand command)
        {
            if (command != null)
            {
                if (!string.IsNullOrEmpty(command.Result))
                {
                    return command.Result;
                }
                else
                {
                    return "错误信息:" + command.Error;
                }

            }
            else
            {
                return "NULL ERROR";
            }
        }



        public string GetSSHClientResult_CMD(string Cmd)
        {
            try
            {
                string result = GetSSHClientResult(ssh_Client.RunCommand(Cmd));

                if (result != string.Empty)
                {
                    return result;
                }
                else
                {
                    return "SFP不存在";
                }
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }



        private void button4_Click(object sender, EventArgs e)
        {
            #region 测试文件
            string result = @"list = Not listing devices          

           interface = NOT_DEFINED          

           info = No          

           poll = No          

           poll period = -1          

           hotplug  = No          

           rx_los   = No          

           mod_abs  = No          

           tx_fault = No          

           scan = No          

           diagnose = Yes          

----------------------------

We are running on CONFIG_FCT board

Scanning all existing SFPs

DDAL_SFP_0 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR133507511    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 59.671875, coherency = 0

           Input power = 0.545900, coherency = 0

           Input power in dbm = -2.628869

           Output power = 0.488400, coherency = 0

           Output power in dbm = -3.112244

           Voltage = 3.226300, coherency = 0

           Current = 41.382004, coherency = 0

DDAL_SFP_1 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: 610105880019   

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 60.000000, coherency = 0

           Input power = 0.524400, coherency = 0

           Input power in dbm = -2.803373

           Output power = 0.690000, coherency = 0

           Output power in dbm = -1.611509

           Voltage = 3.201600, coherency = 0

           Current = 38.610001, coherency = 0

DDAL_SFP_2 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-618    

           Revision: 1.0 X: x

           Serial: FR135001205    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 54.328125, coherency = 0

           Input power = 0.402500, coherency = 0

           Input power in dbm = -3.952341

           Output power = 0.471500, coherency = 0

           Output power in dbm = -3.265183

           Voltage = 3.231100, coherency = 0

           Current = 41.382004, coherency = 0

DDAL_SFP_3 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR130404940    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 60.664062, coherency = 0

           Input power = 0.557900, coherency = 0

           Input power in dbm = -2.534436

           Output power = 0.673400, coherency = 0

           Output power in dbm = -1.717269

           Voltage = 3.280300, coherency = 0

           Current = 38.412003, coherency = 0

DDAL_SFP_4 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR133509565    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 63.671875, coherency = 0

           Input power = 0.383500, coherency = 0

           Input power in dbm = -4.162347

           Output power = 0.498500, coherency = 0

           Output power in dbm = -3.023348

           Voltage = 3.270400, coherency = 0

           Current = 39.798000, coherency = 0

DDAL_SFP_5 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: 610105880018   

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 58.828125, coherency = 0

           Input power = 0.499400, coherency = 0

           Input power in dbm = -3.015515

           Output power = 0.410000, coherency = 0

           Output power in dbm = -3.872161

           Voltage = 3.221300, coherency = 0

           Current = 42.570004, coherency = 0

DDAL_SFP_6 -> Not present

DDAL_SFP_7 -> Not present

DDAL_SFP_8 -> Not present

DDAL_SFP_9 -> Not present

DDAL_SFP_10 -> Not present

DDAL_SFP_11 -> Not present

DDAL_SFP_DEV_LOCAL_RADIO_IF_1 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-618    

           Revision: 1.0 X: x

           Serial: FR135001205    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 54.500000, coherency = 0

           Input power = 0.401300, coherency = 0

           Input power in dbm = -3.965309

           Output power = 0.471500, coherency = 0

           Output power in dbm = -3.265183

           Voltage = 3.231100, coherency = 0

           Current = 41.382004, coherency = 0

DDAL_SFP_DEV_LOCAL_RADIO_IF_2 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: 610105880019   

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 60.000000, coherency = 0

           Input power = 0.524400, coherency = 0

           Input power in dbm = -2.803373

           Output power = 0.687200, coherency = 0

           Output power in dbm = -1.629168

           Voltage = 3.201600, coherency = 0

           Current = 38.610001, coherency = 0

DDAL_SFP_DEV_LOCAL_RADIO_IF_3 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR133507511    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 59.671875, coherency = 0

           Input power = 0.545900, coherency = 0

           Input power in dbm = -2.628869

           Output power = 0.488400, coherency = 0

           Output power in dbm = -3.112244

           Voltage = 3.221300, coherency = 0

           Current = 41.382004, coherency = 0

DDAL_SFP_DEV_LOCAL_RADIO_IF_4 -> Not present

DDAL_SFP_DEV_LOCAL_RADIO_IF_5 -> Not present

DDAL_SFP_DEV_LOCAL_SHARED_1 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: 610105880018   

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 58.664062, coherency = 0

           Input power = 0.499400, coherency = 0

           Input power in dbm = -3.015515

           Output power = 0.408400, coherency = 0

           Output power in dbm = -3.889143

           Voltage = 3.226300, coherency = 0

           Current = 42.570004, coherency = 0

DDAL_SFP_DEV_LOCAL_SRIO_1 -> Not present

DDAL_SFP_DEV_LOCAL_SRIO_2 -> Not present

DDAL_SFP_DEV_LOCAL_TRS_1 -> Not present

DDAL_SFP_DEV_LOCAL_TRS_2 -> Not present

DDAL_SFP_DEV_FSP_1_SRIO_1 -> Not present

DDAL_SFP_DEV_FSP_1_SRIO_2 -> Not present

DDAL_SFP_DEV_FSP_2_SRIO_1 -> Not present

DDAL_SFP_DEV_FSP_3_SRIO_1 -> Not present

DDAL_SFP_DEV_FSP_2_SRIO_2 -> Not present

DDAL_SFP_DEV_FSP_3_SRIO_2 -> Not present

DDAL_SFP_DEV_FSP_2_RADIO_IF_1 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR130404940    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 60.828125, coherency = 0

           Input power = 0.559100, coherency = 0

           Input power in dbm = -2.525105

           Output power = 0.673400, coherency = 0

           Output power in dbm = -1.717269

           Voltage = 3.275400, coherency = 0

           Current = 38.412003, coherency = 0

DDAL_SFP_DEV_FSP_3_RADIO_IF_1 -> Present, info:

           Vendor: WTD            

           Part number: RTXM228-601    

           Revision: 1.0 X: x

           Serial: FR133509565    

           Connector: 7

           Bitrate: 61

           Bitrate (Upper): 5

           Bitrate (Lower): 5

           Wavelength: 1310

           Compliance Code: 3

           Temperature = 63.671875, coherency = 0

           Input power = 0.384700, coherency = 0

           Input power in dbm = -4.148778

           Output power = 0.498500, coherency = 0

           Output power in dbm = -3.023348

           Voltage = 3.270400, coherency = 0

           Current = 39.798000, coherency = 0

DDAL_SFP_DEV_FTM_TRS_1 -> Not present

DDAL_SFP_DEV_FTM_TRS_2 -> Not present

DDAL_SFP_DEV_FTM_SRIO_1 -> Not present"
                ;
            #endregion

   
            string ErrMsg = "";
            List<DDAL_SFP> DDAL_SFPLIST = new List<DDAL_SFP>();
            List<DDAL_SFP_DEV_LOCAL_RADIO_IF> DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new List<DDAL_SFP_DEV_LOCAL_RADIO_IF>();

            if (result.IndexOf("No such file or directory") == -1)
            {
                DDAL_SFPLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFPmodelList(result);
                DDAL_SFP_DEV_LOCAL_RADIO_IFLIST = new BLL.GET_DDAL_SFP().GetDDAL_SFP_DEV_LOCAL_RADIO_IF_modelList(result);
                BindText(DDAL_SFPLIST, DDAL_SFP_DEV_LOCAL_RADIO_IFLIST, "FSMF");
            }
            else
            {
                ErrMsg = "文件操作失败";
                rtxt_FSMF.Text = ErrMsg;
                rtxt_FSMF.BackColor = System.Drawing.Color.Red;
            }

        }


        /* private void button1_Click_1(object sender, EventArgs e)
         {
             string x5 = "0x5F 0x00 0xD8 0x00 0x55 0x00 0xDD 0x00 0x8C 0xA0 0x75 0x30 0x87 0x28 0x7A 0xA8 0x9C 0x40 0x13 0x88 0x88 0xB8 0x1D 0x4C 0x31 0x2D 0x09 0x5F 0x2B 0xD4 0x0B 0xCC 0x31 0x2D 0x00 0x9E 0x2B 0xD4 0x01 0x6B";

             int old = richText_5.Text.Length;
             string x6 = GetHexStringEx(x5);

             richText_5.AppendText(x6);
             SetSFPFontColor(old);
         }*/

        //private void MianWindowShow_Load(object sender, EventArgs e)
        //{
        //    string x = "0x5A";
        //    decimal z = CommonClass.StringHander.Common.GetHexString(x,0);
        //    ;
        //    ;
        //}
        /// <summary>
        /// SSH.NET  SSHClient 返回结果的方法
        /// </summary>
        /// <param name="Cmd"></param>
        /// <returns></returns>


        public string GetSSHClientResult_CMD(Renci.SshNet.SshClient _ssh_Client, string Cmd)
        {
            try
            {
                string result = GetSSHClientResult(_ssh_Client.RunCommand(Cmd));

                if (result != string.Empty)
                {
                    return result;
                }
                else
                {
                    return "SFP不存在";
                }
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }



        private void 命令下发DemoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FlieUpLoadToLinux z = new FlieUpLoadToLinux();
            z.Show();
        }


        private void SecureCRTexeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ThreadTest tt = new ThreadTest()
            {
                str1 = "SecureCRT.exe"
            };
            Thread thread = new Thread(new ThreadStart(tt.startcmd));
            thread.Start();
        }
        public class ThreadTest
        {
            public string str1;
            public void startcmd()
            { //string command, string argument
                Process cmd = new Process();
                cmd.StartInfo.FileName = str1;
                cmd.StartInfo.UseShellExecute = false;
                cmd.StartInfo.RedirectStandardInput = true;
                cmd.StartInfo.RedirectStandardOutput = true;
                cmd.StartInfo.CreateNoWindow = true;
                cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                cmd.Start();

                cmd.StandardInput.WriteLine("exit");

                string ss = cmd.StandardOutput.ReadToEnd();
                cmd.WaitForExit();
                cmd.Close();
            }
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void richText_1_TextChanged(object sender, EventArgs e)
        {

        }

    }

}